<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<s:head/>
<head>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.bgiframe.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/cleditor/jquery.cleditor.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/cts/js/cleditor/jquery.cleditor.css" type="text/css" />
</head>
<body>
<form id="workDocContentForm" name="workDocContentForm" method="post">
	<s:if test="#request.workDoc != null">
		<div style="width: 100%;height: 100%;">
			<table id="table_docinfo_1" style="width: 100%;text-align: left;">
				<tr>
					<td width="40%" style="padding-left: 10px">
						作者：
						<s:if test="#request.parentWorkDoc != null">
							<s:property value="#request.parentWorkDoc.employee.nickname"/>
						</s:if>
						<s:else>
							<s:property value="#request.workDoc.employee.nickname"/>
						</s:else>
					</td>
					<td width="60%" style="text-align: right;padding-right: 10px">
						创建时间：
						<s:if test="#request.parentWorkDoc != null">
							<s:date name="#request.parentWorkDoc.operateTime" format="yyyy-MM-dd"/>
							&nbsp;&nbsp;&nbsp;&nbsp;
							最后编辑：<s:property value="#request.workDoc.employee.nickname"/>&nbsp;&nbsp;
							<s:date name="#request.workDoc.operateTime" format="yyyy-MM-dd HH:mm"/>
						</s:if>
						<s:else>
							<s:date name="#request.workDoc.operateTime" format="yyyy-MM-dd"/>
						</s:else>
					</td>
				</tr>
			</table>
			<table id="table_docinfo_2" style="width: 100%;text-align: left;">
				<tr>
					<td width="55%" style="padding-left: 10px">
						共享访客：<s:property value="#request.shareUserName"/>
					</td>
					<td style="text-align: right;height: 26px;vertical-align: middle;padding-right: 10px" width="45%">
						<s:if test="#request.parentWorkDoc != null && #request.isEdit != 1">
							<span id="span_history_1">
								<a style="color: #637797;cursor: pointer;text-decoration: none" href="javascript: showHistoryList();">查看历史快照</a>
							</span>
							<span id="span_history_2" style="display: none">
								历史快照：
								<select style="width: 150px" id="historylist" name="historylist" onchange="changeHistory()">
									<s:iterator value="%{#request.childDocs}">
										<option value="<s:property value="id"/>"><s:property value="option4"/></option>
									</s:iterator>
								</select>
								<a style="color: #637797;cursor: pointer;text-decoration: none" href="javascript: showLastestHistory('<s:property value="#request.workDoc.id"/>');">查看最新</a>
							</span>
						</s:if>
					</td>
				</tr>
			</table>
			<s:if test="#request.isEdit != 1">
				<iframe id="iframe_workdoccontent" name="iframe_workdoccontent" frameborder="0" style="width: 97%;margin-left: 12px;margin-bottom: 10px;background-color: #fff;min-height: 580px" scrolling="auto" src="loadWorkDocContent?ajaxLoad=1&workDocId=<s:property value="#request.workDoc.id"/>"></iframe>
			</s:if>
			<s:else>
				<s:if test="#request.option4 == 1">
					<div style="padding-left: 10px">
						<s:optiontransferselect 
							name="employeeLeft" 
				            leftTitle="全部访客"
				            list="#request.employees1" 
				            listKey="id" 
				            listValue="nickname" 
							multiple="true" 
				            emptyOption="false" 
				            allowUpDownOnLeft="false" 
				            cssStyle="width:322px;height:250px;" 
				            rightTitle="共享的访客" 
				            doubleList="#request.employees2" 
				            doubleListKey="id" 
				            doubleListValue="nickname" 
				            doubleName="employeeRight" 
				            doubleEmptyOption="false" 
				            doubleMultiple="true" 
				            allowUpDownOnRight="false" 
				            buttonCssStyle="width: 40px;color:black"
				            doubleCssStyle="width:322px;height:250px;" 
						/>
					</div>
				</s:if>
				<div id="div_doccontent" style="margin: 0px 16px 0px 13px;background-color: #fff">
					<textarea name="workDocContent" id="workDocContent" style="height: 400">
						<s:if test="#request.parentWorkDoc != null">
							<s:property value="#request.workDoc.content"/>
						</s:if>
						<s:else>
							<s:property value="#request.workDoc.docTemplate.content"/>
						</s:else>
					</textarea>
					<script type="text/javascript">
						$('#workDocContent').cleditor({width: $('#div_doccontent').width(), height: 400})
					</script>
				</div>
				<div style="width: 100%;text-align: right;margin-top: 10px">
					<input type="hidden" name="workDocId" value="<s:property value="#request.workDocId"/>"/>
					<input type="hidden" name="option4" value="<s:property value="#request.option4"/>"/>
					<input type="hidden" name="fileAddType" value="0"/>
			    	<input type="button" class="btn_ok" onclick="saveWorkDocContent()" value="保存" />
			    </div>
			</s:else>
		</div>
	</s:if>
</form>
</body>
</html>
<script type="text/javascript">
	function showHistoryList(){
		$('#span_history_1').hide();
		$('#span_history_2').show();
	}
	
	function changeHistory(){
		var selectedId = $('#historylist option:selected').val();
		var firstId = $('#historylist option:first').val();
		var url = 'loadWorkDocContent?ajaxLoad=1&workDocId=' + selectedId + '&randomKey=' + Math.random();
		if(firstId != selectedId){
			url += '&isHistory=1';
		}
		document.getElementById("iframe_workdoccontent").src = url;
	}
	
	var isIframeHeightFixed = false;
	function fixedIframeHeight(){
		if(!isIframeHeightFixed){
			var remainHeight = $('#div_file_editor').height() - $('#table_docinfo_1').height() - $('#table_docinfo_2').height();
			$('#iframe_workdoccontent').height(remainHeight - 10);
		}
		isIframeHeightFixed = true;
	}
	
	function fixedUnReadCount(unReadCount){
		var obj = $('div.flie_active_div').find('img');
		if(unReadCount == ''){
			obj.hide();
		}else{
			var src = obj.attr('src');
			src = src.substring(0, src.lastIndexOf('_') + 1) +  unReadCount + src.substring(src.lastIndexOf('.'));
			obj.attr('src', src).show();
		}
	}
	
	function showLastestHistory(workDocId){
		$('#span_history_1').show();
		$('#span_history_2').hide();
		$('#historylist').val(workDocId);
		changeHistory();
	}
</script>






